package com.bjtu.lms.action.book;

import com.bjtu.lms.model.Book;
import com.bjtu.lms.service.BookService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import java.util.List;
import java.util.Map;

/**
 *
 * @author yilee
 */
public class SearchBookAction extends ActionSupport {

	private String type;
	private String value;
	private BookService bookService;

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public BookService getBookService() {
		return bookService;
	}

	public void setBookService(BookService bookService) {
		this.bookService = bookService;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Override
	public String execute() throws Exception {
		System.out.println("type=" + type + "value" + value);
		List<Book> bookList = bookService.searchBooks(type, value);
		ActionContext actionContext = ActionContext.getContext();
		Map session = actionContext.getSession();
		session.put("bookList", bookList);
		session.put("search", value);
		return SUCCESS;
	}
}
